<?php

namespace app\model;

use think\Model;

class CustomerDongtai extends Model
{

    protected $connection = 'mysql';

    protected $pk = 'id';

    protected $name = 'customer_dongtai';


    public static function getlist($cid) {
        return self::where(['cid' => $cid])->order('id desc')->select()->toArray();
    }

    public static function getnewone($cid) {
        $ret = self::where(['cid' => $cid])->find();
        if(!empty($ret)){
            $ret = $ret->toArray();
        }
        return $ret;
    }

    public static function getcount($where) {
        $query = self::where($where);

        $getdata['date_start'] = date("Y-m-d H:i:s", strtotime("-1 day"));

        $getdata['date_end'] = date("Y-m-d H:i:s");

        if (!empty($getdata['date_start'])) {
            $query->andWhere('create_time','>=', strtotime(trim($getdata['date_start'])));
        }
        if (!empty($getdata['date_end'])) {
            $query->andWhere('create_time','<=', strtotime(trim($getdata['date_end'])) + 86400);
        }

        return $query->count();
    }
}
